
import type { AxiosRequestConfig } from 'axios';
import axios from './index'

interface AxiosType {
    method: string,
    url: string,
    params: (string | number)[],
    data: (string | number)[],
    config: AxiosRequestConfig<(string | number)[]>,
}

const http = (method: string, url: string, params: (string | number)[], data: (string | number)[]) => {
    return new Promise(async (resolve, reject) => {
        try {
            const res = await axios({
                method,
                url,
                params,
                data,
            });
            console.log(res);
            if (res.status == 200 && res.data && res.data.status == 'success') {
                resolve(res.data.data);
            }
        } catch (err) {
            console.log(err);
            reject(err);
        }
    })
}

export default http